<?php
namespace App\Logic\Gateio;

use Illuminate\Support\Facades\Cache;
use GuzzleHttp\Client;

class GateIo
{
    public static function index()
    {

        $arr = get_type_arr();
        $client = new Client;
        //group_hour
        //group_sec
        foreach($arr as $v){

             $url = 'https://data.gateio.life/api2/1/candlestick2/'.$v.'?group_sec=3600&range_hour=23';
             $res = $client->get($url);
             $data = json_decode($res->getBody(),true);

             if($data['result'] === 'true') {
                 Cache::set($v,$data['data']);
             }
        }

    }

    public static function tickets()
    {

        $client = new Client;
        $res = $client->get('https://data.gateio.life/api2/1/tickers');
        $data = json_decode($res->getBody(),true);
        if(isset($data['eth_btc'])) {
            Cache::set('tickets',$data);
        }

    }
    public static function marketList()
    {


        $client = new Client;
        $res = $client->get('https://data.gateio.life/api2/1/marketlist');
        $data = json_decode($res->getBody(),true);
        if($data['result'] == 'true') {

            Cache::set('marketlist',$data['data']);
        }

    }


}





